/*
 * Apache License Version 2.0, January 2004 http://www.apache.org/licenses/
 * 
 * Copyright 2009 by Sebastián Zaffarano
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 */
package org.sigedu.utils;

import java.io.Serializable;
import java.util.LinkedList;
import java.util.List;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;

/**
 * @author sebas
 * 
 * @version $Id$
 */
public class Item implements Serializable {
	private static final long serialVersionUID = 6020177410059207725L;

	private String name;

	private String description;

	private Object data;
	
	private List<Item> childs = new LinkedList<Item>();

	public Item() {

	}

	public Item(final String name, final String description) {
		this.name = name;
		this.description = description;
	}

	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * @param name
	 *            the name to set
	 */
	public void setName(final String name) {
		this.name = name;
	}

	/**
	 * @return the description
	 */
	public String getDescription() {
		return description;
	}

	/**
	 * @param description
	 *            the description to set
	 */
	public void setDescription(final String description) {
		this.description = description;
	}

	/**
	 * @return the childs
	 */
	public List<Item> getChilds() {
		return childs;
	}

	/**
	 * @param childs
	 *            the childs to set
	 */
	public void setChilds(final List<Item> childs) {
		this.childs = childs;
	}

	/**
	 * @return the data
	 */
	public Object getData() {
		return data;
	}

	/**
	 * @param data
	 *            the data to set
	 */
	public void setData(final Object data) {
		this.data = data;
	}

	@Override
	public boolean equals(final Object other) {
		if (this == other) {
			return true;
		}
		if (!(other instanceof Item)) {
			return false;
		}
		Item castOther = (Item) other;
		return new EqualsBuilder().append(name, castOther.name).append(description, castOther.description).append(
				childs, castOther.childs).isEquals();
	}

	@Override
	public int hashCode() {
		return new HashCodeBuilder().append(name).append(description).append(childs).toHashCode();
	}

	@Override
	public String toString() {
		return new ToStringBuilder(this).appendSuper(super.toString()).append("name", name).append("description",
				description).append("childs", childs).toString();
	}
}
